package com.example.juc.until;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.stream.Stream;

public class StreamTest {
        public static void main(String[] args) {
                //stream流式编程
                User u1= new User(1,"rt1",13);
                User u2= new User(2,"hg2",16);
                User u3= new User(3,"da3",21);
                User u4= new User(4,"sa4",26);
                User u5= new User(6,"fs5",28);
                //添加到集合
                List<User> list = Arrays.asList(u1, u2, u3, u4, u5);
                list.stream()
                        .filter((u) ->{return u.getId()%2==0;})  //id为偶数
                        .filter((u) -> {return u.getAge()>23;})  //年龄大于23
                        .map((u) -> {return u.getName().toUpperCase();})  //名字大写
                        .sorted()                                         //倒序
                        .limit(1)                                         //分页
                        .forEach(System.out::println);

        }
}
